package com.jingtai.shop.webfacade.bo.shopcar;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.jingtai.common.webfacade.BaseBO;
import com.jingtai.common.webfacade.error.CommonException;
import com.jingtai.common.webfacade.error.ErrorEnum;
import com.jingtai.validate.swagger.CApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 下单-总单
 */
@Data
public class SubmitOrderTotalBO extends BaseBO {
    /**
     * 商户ID
     */
    private Long merchantsId;
    /**
     * 用户收货地址ID
     */
    private Long memberAddressId;
    /**
     * 商品总价
     */
    private BigDecimal goodsTotalPrice;
    /**
     * 运费总价
     */
    private BigDecimal totalFreight;

    /**
     * 优惠价总价
     */
    private BigDecimal preferentialTotalPrice;

    /**
     * 用户实付价格总价
     */
    private BigDecimal memberRealTotalPay;

    /**
     * 商品信息
     */
    private List<SubmitOrderDetailBO> orderDetailsBOS;


    /**
     * 检查参数是否正确
     */
    @Override
    public void validate() {
        super.validate();

        if (ObjectUtil.isEmpty(memberAddressId) || ObjectUtil.isEmpty(goodsTotalPrice)
                || ObjectUtil.isEmpty(merchantsId)
                || ObjectUtil.isEmpty(totalFreight)
                || ObjectUtil.isEmpty(preferentialTotalPrice)
                || ObjectUtil.isEmpty(memberRealTotalPay)
                || CollectionUtil.isEmpty(orderDetailsBOS)) {
            throw new CommonException(ErrorEnum.REQUIRED_PARAM_EMPTY);
        }
    }

}
